package com.schoolcloud.social.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.schoolcloud.common.model.PageDTO;
import com.schoolcloud.social.entity.SocPostTags;
import com.schoolcloud.social.query.PostTagQuery;
import com.schoolcloud.social.service.SocPostTagsService;
import com.schoolcloud.social.mapper.SocPostTagsMapper;
import com.schoolcolud.daomybatisplus.dto.MpPageUtil;
import org.springframework.stereotype.Service;

/**
* @author hongmizfb
* @description 针对表【soc_post_tags(标签表)】的数据库操作Service实现
* @createDate 2025-03-08 22:30:29
*/
@Service
public class SocPostTagsServiceImpl extends ServiceImpl<SocPostTagsMapper, SocPostTags>
    implements SocPostTagsService{

    @Override
    public PageDTO<SocPostTags> getPostTagPage(PostTagQuery query) {
        String keywords = query.getKeywords();
        String categoryId = query.getCategoryId();
        Page<SocPostTags> page = lambdaQuery().like(StrUtil.isNotBlank(keywords), SocPostTags::getTagName, keywords)
                .eq(StrUtil.isNotBlank(categoryId), SocPostTags::getCategoryId, categoryId)
                .page(query.toMpPage());
        return MpPageUtil.of(page, SocPostTags.class);
    }
}




